//
//  ViewController.m
//  TomCat
//
//  Created by student on 16/2/21.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)packageWithFirst:(int)first andLast:(int)last andPicname:(NSString *)picname andTimer:(int)time
{
    NSMutableArray *mArr = [[NSMutableArray alloc]init];
    for (int i=first; i<=last; i++)
    {
        NSString *pic;
        if(i<10)
        {
            pic = [NSString stringWithFormat:@"%@_0%i",picname,i];
        }
        else
        {
            pic = [NSString stringWithFormat:@"%@_%i",picname,i];
        }
        UIImage *image = [UIImage imageNamed:pic];
        [mArr addObject:image];
    }
    self.imageView.animationImages = mArr;
    self.imageView.animationRepeatCount = 1;
    self.imageView.animationDuration = time;
    [self.imageView startAnimating];
}
- (IBAction)cymbalBtn:(id)sender
{
    [self packageWithFirst:0 andLast:12 andPicname:@"cymbal" andTimer:1];
}
- (IBAction)drinkBtn:(id)sender
{
    [self packageWithFirst:0 andLast:80 andPicname:@"drink" andTimer:5];
}
- (IBAction)eatBtn:(id)sender {
    [self packageWithFirst:0 andLast:39 andPicname:@"eat" andTimer:3];
}
- (IBAction)fartBtn:(id)sender {
    [self packageWithFirst:0 andLast:27 andPicname:@"fart" andTimer:2];
}
- (IBAction)pieBtn:(id)sender {
     [self packageWithFirst:0 andLast:23 andPicname:@"pie" andTimer:2];
}
- (IBAction)sctatchBtn:(id)sender {
     [self packageWithFirst:0 andLast:55 andPicname:@"scratch" andTimer:4];
}
- (IBAction)left:(id)sender {
    [self packageWithFirst:0 andLast:29 andPicname:@"footRight" andTimer:2];
}
- (IBAction)right:(id)sender {
     [self packageWithFirst:0 andLast:29 andPicname:@"footLeft" andTimer:2];
}
- (IBAction)Stomach:(id)sender {
     [self packageWithFirst:0 andLast:33 andPicname:@"stomach" andTimer:3];
}
- (IBAction)scratch:(id)sender {
     [self packageWithFirst:0 andLast:25 andPicname:@"angry" andTimer:2];
}
- (IBAction)KnockOut:(id)sender {
     [self packageWithFirst:0 andLast:80 andPicname:@"knockout" andTimer:5];
}

@end
